<template>
  <div class="screen-block">
    <div class="content_title">重点品类排名</div>
    <BorderBox1>
      <div id="mainMap2" style="width: 100%; height: 100%"></div>
    </BorderBox1>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
import { BorderBox1 } from '@kjgl77/datav-vue3';
// import * as echarts from 'echarts';
import { init, EChartsOption } from 'echarts';

const initalECharts4 = () => {
  const myChart = init(document.getElementById('mainMap2') as HTMLDivElement);
  let option: EChartsOption = {
    color: {
      type: 'linear',
      x: 0,
      y: 0,
      x2: 1,
      y2: 0,
      colorStops: [
        {
          offset: 0,
          color: '#d000d0', // 0% 处的颜色
        },
        {
          offset: 1,
          color: '#7006d9', // 100% 处的颜色
        },
      ],
      globalCoord: false,
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // 坐标轴指示器，坐标轴触发有效
        type: 'shadow', // 默认为直线，可选为：'line' | 'shadow'
      },
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'value',
        splitLine: {
          show: true,
          lineStyle: {
            color: ['#07234d'],
          },
        },
        axisLabel: {
          show: true,
          textStyle: {
            color: '#c3dbff', //更改坐标轴文字颜色
            fontSize: 12, //更改坐标轴文字大小
          },
        },
      },
    ],
    yAxis: [
      {
        type: 'category',
        data: ['科技', '母婴', '男士', '美妆', '珠宝', '宠物'],
        axisTick: {
          alignWithLabel: true,
        },
        axisLabel: {
          show: true,
          textStyle: {
            color: '#c3dbff', //更改坐标轴文字颜色
            fontSize: 12, //更改坐标轴文字大小
          },
        },
      },
    ],
    series: [
      {
        name: '直接访问',
        type: 'bar',
        barWidth: '60%',
        data: [10, 52, 200, 334, 390, 330],
      },
    ],
  };
  myChart.setOption(option);
};
onMounted(() => {
  initalECharts4();
});
</script>

<style lang="scss" scoped>
.screen-block {
  width: 100%;
  height: 100%;
  position: relative;
  .content_title {
    width: 200px;
    text-align: center;
    color: #01c4f7;
    font-size: 14px;
    position: absolute;
    top: 0;
    left: 50%;
    margin-left: -100px;
  }
}
</style>
